package com.hunan.api.catv.entity.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 竞猜排行榜表
 * </p>
 *
 * @author jiangzhuan
 * @since 2021-06-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("guessing_ranking")
public class GuessingRanking extends Model<GuessingRanking> {

    private static final long serialVersionUID = 1L;

    /**
     * 竞猜用户id
     */
    private Integer memberId;

    /**
     * 活动类型： 2：欧洲杯竞猜活动
     */
    private Integer activityType;

    /**
     * 竞猜成功累计数
     */
    private Integer winNum;

    /**
     * 竞猜成功最大累计数
     */
    private Integer maxNum;

    /**
     * 扩展字段，json格式
     */
    private String rankingExtend;

    /**
     * 逻辑删除 0:已删除 1:未删除
     */
    private Integer deleted;

    /**
     * 最近一次更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;


    public static final String MEMBER_ID = "member_id";

    public static final String ACTIVITY_TYPE = "activity_type";

    public static final String WIN_NUM = "win_num";

    public static final String MAX_NUM = "max_num";

    public static final String RANKING_EXTEND = "ranking_extend";

    public static final String DELETED = "deleted";

    public static final String UPDATE_TIME = "update_time";

    @Override
    protected Serializable pkVal() {
        return this.memberId;
    }

    public static GuessingRanking initBot(Integer memberId) {
        GuessingRanking guessingRanking = new GuessingRanking();
        guessingRanking.setMemberId(memberId);
        guessingRanking.setActivityType(2);
        guessingRanking.setDeleted(1);
        guessingRanking.setMaxNum(0);
        guessingRanking.setWinNum(0);
        guessingRanking.setUpdateTime(new Date());
        return guessingRanking;
    }

    public static GuessingRanking copyBot(Integer memberId,GuessingRanking origin) {
        GuessingRanking guessingRanking = new GuessingRanking();
        guessingRanking.setMemberId(memberId);
        guessingRanking.setActivityType(2);
        guessingRanking.setDeleted(1);
        guessingRanking.setMaxNum(origin.getMaxNum());
        guessingRanking.setWinNum(origin.getWinNum());
        guessingRanking.setUpdateTime(new Date());
        return guessingRanking;
    }

}
